<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

use Think\Model;

class OrderDetail
{
    public $login = false; //是否需要登录才能访问该接口
    public $title = "订单详情ok";
    public $group = '订单';
    public $desc = "";

    public $input = [
        'order_no' => 'required;label=订单号;',
    ];

    public $output = [
        [
            'id' => 'label=id;',
            'order_no' => 'label=订单号;',
            'buy_num' => 'label=购买数量;',
            'total_money' => 'label=应付金额;',
            'pay_money' => 'label=实付金额;',
            'order_type' => 'label=订单类型：0房租缴纳 1物业费缴纳 2水费缴纳 3电费缴纳;',
            'contact_code' => 'label=合同编号;',
            'building_id' => 'label=楼栋id;',
            'house_id' => 'label=房间id;',
            'start_time' => 'label=缴纳开始时间;',
            'end_time' => 'label=缴纳结束时间;',
            'num' => 'label=缴纳月数;',
        ]
    ];

    public function run($param, $uid)
    {

        $list = M('order')->where(['order_no' => $param['order_no']])->find();
        if(!$list) throw new \Exception('未找到该订单');
        $order_detail = M('order_detail')->where(['order_no' => $param['order_no']])->find();
        $result = array_merge($list, $order_detail);
        return $result;
    }
}
